home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / etc / init.d / 915resolution next >
Encoding:
Text File  |  2007-02-12  |  3.0 KB  |  105 lines

  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          915resolution
  4. # Required-Start:    $syslog
  5. # Required-Stop:     $syslog
  6. # Should-Start:      $local_fs
  7. # Should-Stop:       $local_fs
  8. # Default-Start:     2 3 4 5
  9. # Default-Stop:      0 1 6
  10. # Short-Description: Set the resolution for special chipset
  11. # Description:       The right resolution mode will be set and given
  12. #                    to the X server
  13. ### END INIT INFO
  14.  
  15. PATH=/sbin:/bin:/usr/sbin:/usr/bin
  16. PROG=/usr/sbin/915resolution
  17. NAME=915resolution
  18. DESC=915resolution
  19. VBETOOL=/usr/sbin/vbetool
  20.  
  21. test -x $PROG || exit 0
  22.  
  23. # Include 915resolution defaults if available
  24. if [ -f /etc/default/915resolution ] ; then
  25.     . /etc/default/915resolution
  26. fi
  27.  
  28. wrong_chipset()
  29. {
  30.     echo "Wrong chipset detected. 915resolution only works with Intel 800/900 series graphic chipsets."
  31.     exit 0
  32. }
  33.  
  34. $PROG -l >/dev/null 2>&1 || wrong_chipset
  35.  
  36. if [ "$MODE" = auto -a \! -x "$VBETOOL" ] || [ "$MODE" != auto -a \( -z "$MODE" -o -z "$XRESO" -o -z "$YRESO" \) ] ; then
  37.    echo "*** Your 915resolution hasn't been configured! ***"
  38.    echo "Please read /usr/share/doc/915resolution/README.Debian and define"
  39.    echo "MODE, XRESO, and YRESO."
  40.    exit 0
  41. fi
  42.  
  43. auto_select_modes()
  44. {
  45.     if [ ! -x "$VBETOOL" ] || ! panelsize=`$VBETOOL vbefp panelsize` ; then
  46.     echo "*** Your 915resolution was not automatically configured! ***"
  47.     echo "Please read /usr/share/doc/915resolution/README.Debian then define"
  48.         echo "MODE, XRESO, and YRESO manually in /etc/default/915resolution ."
  49.     echo "For now a default will be set, which might be inappropiate."
  50.     XRESO=1024
  51.     YRESO=768
  52.     fi
  53.  
  54.     # If the native panel-size is already in the BIOS mode list, we
  55.     # don't have to do anything, yippee!
  56.     bios_list=`$PROG -l`
  57.     if echo "$bios_list" | grep -q "^Mode .* $panelsize" ; then
  58.     #echo 'Correct panel-size is already listed, skipping'
  59.     return
  60.     fi
  61.  
  62.     # For want of a better approach to selecting modelines for stealing;...
  63.     # this expression grabs us the highest *numbered* mode in each
  64.     # bit-depth that the BIOS already lists.
  65.     #
  66.     # An argument for using the highest mode-number, rather than the
  67.     # highest resolution is that if we've already reprogrammed the
  68.     # mode to be a lower resolution it will no longer be the highest.
  69.     # If this has changed over a suspend cycle, that consequences
  70.     # might not be so good.  -Paul Sladen
  71.     target_modes=`echo "$bios_list" | awk '/^Mode [^T]/{sub(",","",$4); print $5,$4,$2}' | tac | sort -n -u | cut -d' ' -f3`
  72.  
  73.     for m in $target_modes ; do
  74.     # The 'tr' converts '1024x768' -> '1024' '768'
  75.     # and the bitdepth is missed off because we have one of each depth
  76.     $PROG $m $(echo $panelsize | tr x ' ')
  77.     done
  78. }
  79.  
  80. set -e
  81.  
  82. case "$1" in
  83.   start|restart|force-reload)
  84.     echo -n "Starting $DESC: "
  85.     if [ "$MODE" = "auto" ] ; then
  86.         auto_select_modes
  87.     else
  88.         $PROG $MODE $XRESO $YRESO $BIT
  89.     fi    
  90.     echo "$NAME."
  91.     ;;
  92.   stop)
  93.     #echo -n "Stopping $DESC: "
  94.     #echo "$NAME."
  95.     ;;
  96.   *)
  97.     N=/etc/init.d/$NAME
  98.     # echo "Usage: $N start" >&2
  99.     echo "Usage: $N start" >&2
  100.     exit 1
  101.     ;;
  102. esac
  103.  
  104. exit 0
  105.